package leetcode;

import java.lang.reflect.Array;
import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 东莞呵呵
 * Date:2022-07-06
 * Time:21:58
 */
public class TestDemo2 {
    public static void main(String[] args) {
        int[] nums={1};
        removeElement(nums,1);
        System.out.println(Arrays.toString(nums));
    }

    public static int removeElement(int[] nums, int val) {
        int length = nums.length - 1;
        for (int i = 0; i < nums.length; i++) {
            while (nums[i] == val&&i<= length) {
                for (int j = i; j < length; j++) {
                    nums[j] = nums[j + 1];
                }
                length--;
            }
        }
        return length+1;
    }
}
